package com.dk.base.web.facade;

import com.dk.base.common.model.DemoDTO;
import com.dk.base.common.proxy.DemoProxyFacade;
import com.dk.base.core.service.DemoService;
import com.dk.common.exception.BusinessException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Random;


@Slf4j
@RestController
@RequestMapping(DemoProxyFacade.PREFIX)
public class DemoProxyFacadeImpl implements DemoProxyFacade {

    @Autowired
    private DemoService demoService;


    @Override
    public List<DemoDTO> list() {
        Random random = new Random();
        if(random.nextBoolean()){
            throw new BusinessException("出现异常！");
        }
        return demoService.list();
    }
}
